import { needShareCode, confirmShareCode, shareFile, getShare } from '@/api/share';

const actions = {
  needShareCode({ commit }, param) {
    return new Promise((resolve, reject) => {
      needShareCode(param)
        .then(res => {
          const { data } = res;
          if (data) {
            console.log(data);
          }
          resolve(data);
        })
        .catch(err => {
          reject(err);
        });
    });
  },
  confirmShareCode({ commit }, param) {
    return new Promise((resolve, reject) => {
      confirmShareCode(param)
        .then(res => {
          const { data } = res;
          if (data) {
            console.log(data);
          }
          resolve(data);
        })
        .catch(err => {
          reject(err);
        });
    });
  },
  shareFile({ commit }, param) {
    return new Promise((resolve, reject) => {
      shareFile(param)
        .then(res => {
          const { data } = res;
          if (data) {
            console.log(data);
          }
          resolve(data);
        })
        .catch(err => {
          reject(err);
        });
    });
  },
  getShare({ commit }, param) {
    return new Promise((resolve, reject) => {
      getShare(param)
        .then(res => {
          const { data } = res;
          if (data) {
            console.log(data);
          }
          resolve(data);
        })
        .catch(err => {
          reject(err);
        });
    });
  }
};

export default {
  namespaced: true,
  actions
};
